package com.vlin.message.handler.tuya;

import com.alibaba.fastjson.JSONObject;
import com.vlin.message.handler.MessageHandler;

public abstract class AbstractTuyaMessageHandler implements MessageHandler {

	
	public boolean support(Object object) {
		if(!(object instanceof JSONObject)) {
			return false;
		}
		
		return doSupport(convert(object));
	}
	
	public abstract boolean doSupport(JSONObject object);
	
	public void handle(Object object) {
		if(support(object)) {
			doHandle(convert(object));
		}
	}
	public abstract void doHandle(JSONObject object);
	
	public JSONObject convert(Object object) {
		return (JSONObject) object;
	}
}
